#include "Game.h"
#include "MainScene.h"

using namespace cocos2d;

bool CGame::initInstance()
{
	return true;
}

bool CGame::applicationDidFinishLaunching()
{

	IW_CALLSTACK("CGame::applicationDidFinishLaunching");

	// init the window
	m_pMainWnd = new CCEGLView();
		
	// init director	
	CCDirector *pDirector = CCDirector::sharedDirector();
	pDirector->setOpenGLView(m_pMainWnd);	
	pDirector->setDeviceOrientation(kCCDeviceOrientationPortrait);	
	pDirector->setDisplayFPS(false);
	
	CCScene* mainScene = CCScene::node();

	CCLayer *layer = MainScene::node();
	
	// add layer as a child to scene
	mainScene->addChild(layer);

	pDirector->runWithScene(mainScene);

	return true;
}

void CGame::applicationDidEnterBackground()
{
	IW_CALLSTACK("CGame::applicationDidEnterBackground");    
	CCDirector::sharedDirector()->pause();
}
void CGame::applicationWillEnterForeground()
{
	IW_CALLSTACK("CGame::applicationWillEnterForeground");
    CCDirector::sharedDirector()->resume();
}

CGame::CGame()
:m_pMainWnd(NULL)
{
	IW_CALLSTACK("CGame::CGame");
}

CGame::~CGame()
{
	IW_CALLSTACK("CGame::~CGame");
	CC_SAFE_DELETE(m_pMainWnd);
}

